import QtQuick
import QtQuick.Controls
import "../component/ZGlobal.js" as Global

Rectangle {
    id: rootModelRect
    width: 780
    height: 680
    anchors.centerIn: parent
    property var modelMask
    property Item modelParent

    onVisibleChanged: {
        if(visible){
            modelMask = Global.createModel(root);
            modelParent=rootModelRect.parent;
            rootModelRect.parent=modelMask;
        }else{
            rootModelRect.parent=modelParent;
            if (modelMask !== undefined) modelMask.destroy()
        }
    }

    Behavior on visible {
        SequentialAnimation {
            // 显示时的动画
            ScriptAction {
                script: {
                    if (rootModelRect.visible) {
                        rootModelRect.opacity = 0
                        rootModelRect.scale = 0.3
                    }
                }
            }
            // 并行执行多个属性动画
            ParallelAnimation {
                NumberAnimation {
                    target: rootModelRect
                    property: "opacity"
                    from: 0
                    to: 1
                    duration: 300
                }
                NumberAnimation {
                    target: rootModelRect
                    property: "scale"
                    from: 0.3
                    to: 1
                    duration: 400
                    easing.type: Easing.OutBack
                }
            }
        }
    }
}
